//
//  DetailFourCollectionViewCell.m
//  HandWork
//
//  Created by 王阳阳 on 16/1/21.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DetailFourCollectionViewCell.h"

@interface DetailFourCollectionViewCell ()<UIScrollViewDelegate>

@end

@implementation DetailFourCollectionViewCell
-(void)dealloc
{
    [_img release];
    [_content release];
    [_scroll release];
    [_i release];
    [_j release];
    [super dealloc];
}
#pragma mark - 初始化
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creat];
    }
    return self;
}
- (void)creat
{
    //scrollView
    self.scroll = [[UIScrollView alloc]init];
    [self.contentView addSubview:self.scroll];
    [_scroll release];
    
    //图片
    self.img = [[UIImageView alloc]init];
    [self.scroll addSubview:self.img];
    [_img release];
    //内容
    self.content = [[UILabel alloc]init];
    [self.scroll addSubview:self.content];
    [_content release];
}
#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
//    //scrollview
    self.scroll.frame = self.contentView.frame;
    self.scroll.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, 1000);
    //代理
    self.scroll.delegate = self;
    //图片

    self.img.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width + 100);


    //内容
    CGFloat ch =[[self class] heightWithText:_content.text];
    self.content.frame = CGRectMake(5, self.img.frame.size.height + 10, [UIScreen mainScreen].bounds.size.width - 10, ch);

    //不限制行高
    self.content.numberOfLines = 0;
    
}
#pragma mark - 内容高度
+ (CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};

    CGSize size = CGSizeMake(375 - 20, 1000);
    CGRect r = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return r.size.height;
}

@end
